<?php
/**
 * Created by PhpStorm.
 * User: Raytine
 * Date: 2018/8/8
 * Time: 18:14
 */
namespace PddWechat\Models\User\Service;

use Dai\Framework\Base\BaseService;
use Dai\Framework\Base\BaseSessionInfo;
use PddWechat\Models\User\Data\UserData;

class LeaderInfo extends BaseService
{
    public function __construct()
    {
        $this->userdata = new UserData();
    }

    public function execute($basePageInfo) {
        /** @var BaseSessionInfo $sessionData */
        $sessionData = $basePageInfo->sessionInfo;
        $openid = $sessionData->openId;
        $userInfo = $this->userdata->getUserByOpenId($openid);
        $inviteOpenId = $userInfo->inviteOpenId;
        if(empty($inviteOpenId)) {
            return;
        }
        $leaderInfo = $this->userdata->getUserByOpenId($inviteOpenId);
        return $leaderInfo;
    }
}